# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
#     https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

default_platform(:ios)

platform :ios do
  before_all do
    setup_circle_ci
  end

  desc "Push a new release build to the App Store"
  lane :release do
    increment_build_number(xcodeproj: "App.xcodeproj")
    build_app(workspace: "App.xcworkspace", scheme: "App")
    upload_to_app_store
  end

  desc "Upload Release to App Store"
  lane :upload_release do
    # Get the version number from the project and check against
    # the latest build already available on App Store Connect, then
    # increase the build number by 1. If no build is available
    # for that version, then start at 1
    increment_build_number(
      build_number: app_store_build_number + 1,
    )
    # Set up Distribution code signing and build the app
    match(type: "appstore", readonly: is_ci)
    gym(scheme: "App")
    # Upload the binary to App Store Connect
    app_store_connect_api_key
    deliver(
      submit_for_review: false,
      precheck_include_in_app_purchases: false,
      force: true
    )
  end
end
